package com.cloud.drore.eboss.operation.controller;

import com.cloud.drore.eboos.common.base.ResultMessage;
import com.cloud.drore.eboos.common.constant.CommonConstant;
import com.cloud.drore.eboos.common.constant.ResultCodeConstant;
import com.cloud.drore.eboos.common.entity.operation.po.OrderSourceStatisticsPo;
import com.cloud.drore.eboos.common.entity.operation.vo.IndexLastWeekStatisticsVo;
import com.cloud.drore.eboos.common.entity.operation.vo.NextWeekTouristForecastVo;
import com.cloud.drore.eboos.common.entity.operation.vo.OrderSourceStatisticsVo;
import com.cloud.drore.eboos.common.entity.operation.vo.OrderStatisticsVo;
import com.cloud.drore.eboos.exception.BusinessException;
import com.cloud.drore.eboss.login.user.Anon;
import com.cloud.drore.eboss.operation.entity.po.OrderStatisticsPo;
import com.cloud.drore.eboss.operation.service.IFeignOperationIndex;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/4/11 11:54 <br>
 * @Author: <a href="1451173193@qq.com">杨亮</a>
 */
@RestController
@RequestMapping("/operationIndex")
@Api(value = "运营商-首页接口" , description = "运营商-首页接口-杨亮")
public class OperationIndexController {
    @Resource private IFeignOperationIndex feignOperationIndex;
    @ApiOperation(value = "运营首页获取上周订单，游玩统计信息")
    @GetMapping(value = "/getLastWeekStatistics")
    public ResultMessage<IndexLastWeekStatisticsVo> getLastWeekStatistics() throws BusinessException {
        ResultMessage rm=feignOperationIndex.getLastWeekStatistics();
        if(ResultCodeConstant.SERVICE_SUCCESS_CODE!= rm.getCode()){
            throw new BusinessException(CommonConstant.REMOTE_CALL_ERROR);
        }
        return rm;
    }
    @ApiOperation(value = "运营首页订单数销售统计")
    @PostMapping(value = "/getOrderStatisticsByParams")
    public ResultMessage<List<OrderStatisticsVo>> getOrderStatisticsByParams(@RequestBody @Validated OrderStatisticsPo po) throws BusinessException {
        ResultMessage rm=feignOperationIndex.getOrderStatisticsByParams(po);
        if(ResultCodeConstant.SERVICE_SUCCESS_CODE!= rm.getCode()){
            throw new BusinessException(CommonConstant.REMOTE_CALL_ERROR);
        }
        return rm;
    }
    @ApiOperation(value = "运营首页未来一周游客量")
    @GetMapping(value = "/getNextWeekTouristForecast")
    public ResultMessage<List<NextWeekTouristForecastVo>> getNextWeekTouristForecast() throws BusinessException {
        ResultMessage rm=feignOperationIndex.getNextWeekTouristForecast();
        if(ResultCodeConstant.SERVICE_SUCCESS_CODE!= rm.getCode()){
            throw new BusinessException(CommonConstant.REMOTE_CALL_ERROR);
        }
        return rm;
    }
    @ApiOperation(value = "运营首页订单分销来源，产品来源分销")
    @PostMapping(value = "/getOrderSourceStatisticsByParams")
    public ResultMessage<OrderSourceStatisticsVo> getOrderSourceStatisticsByParams(@RequestBody OrderSourceStatisticsPo po) throws BusinessException {
        ResultMessage rm=feignOperationIndex.getOrderSourceStatisticsByParams(po);
        if(ResultCodeConstant.SERVICE_SUCCESS_CODE!= rm.getCode()){
            throw new BusinessException(CommonConstant.REMOTE_CALL_ERROR);
        }
        return rm;
    }
}
